package com.ibuonline.b2b.entity;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

import com.dimeng.common.util.StringUtil;

public class CompanyFriendlink implements Serializable {

	private static final long serialVersionUID = -1823627789204856664L;

	//fields
	private java.lang.Integer id;
	private java.lang.Integer companyId;
	private java.lang.String title;
	private java.lang.String url;
	private java.sql.Timestamp createTime;
	private java.sql.Timestamp lastupdate;

	//default constructor
	public CompanyFriendlink() {
	}

	//getter
	public java.lang.Integer getId() {
		return id;
	}
	public java.lang.Integer getCompanyId() {
		return companyId;
	}
	public java.lang.String getTitle() {
		return title;
	}
	public java.lang.String getUrl() {
		if(StringUtil.notEmpty(url) && !url.toLowerCase().startsWith("http")) {
			return "http://"+url;
		}
		return url;
	}
	public java.sql.Timestamp getCreateTime() {
		return createTime;
	}
	public java.sql.Timestamp getLastupdate() {
		return lastupdate;
	}

	//setter
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public void setCompanyId(java.lang.Integer companyId) {
		this.companyId = companyId;
	}
	public void setTitle(java.lang.String title) {
		this.title = title;
	}
	public void setUrl(java.lang.String url) {
		this.url = url;
	}
	public void setCreateTime(java.sql.Timestamp me) {
		this.createTime = me;
	}
	public void setLastupdate(java.sql.Timestamp lastupdate) {
		this.lastupdate = lastupdate;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof CompanyFriendlink))
			return false;

		final CompanyFriendlink friendlink = (CompanyFriendlink)other;
		if (!this.id.equals(friendlink.getId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(id).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("CompanyFriendlink[")
			.append("id=").append(id).append(", ")
			.append("companyId=").append(companyId).append(", ")
			.append("title=").append(title).append(", ")
			.append("url=").append(url).append(", ")
			.append("createTime=").append(createTime).append(", ")
			.append("lastupdate=").append(lastupdate).append("]").toString();
	}
	
	///###
	@SuppressWarnings("deprecation")
	public String getPath(){
		if(StringUtil.notEmpty(url)) {
			try {
				return java.net.URLEncoder.encode(url.substring(7),"GBK");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return "";
	}
}